local thing_to_Say = nil

hook.Add("PlayerSay", "ChatBot.Trig", function( ply , text )
	if string.ToTable( text )[1] !=  _ChatPrefix then
		if text == ChatBotSettings.EasterEgg then
			umsg.Start("ChatBot.Call")
				umsg.String( ChatBotSettings.EasterEggAnswer )
			umsg.End()
		end
			
		if string.lower(text) == "hey nick" or string.lower(text) == "hey nick!" or string.lower(text) == "hey!" or string.lower(text) == "hey" then
			local replacement = table.Random( greetings )
			umsg.Start("ChatBot.Call")
				umsg.String( replacement )
			umsg.End()
		end

		for k,v in pairs( string.Explode( " ", text ) ) do
			for key, value in pairs( Tab ) do
				if string.lower(v) == key then
					thing_to_Say = replacement
				end
			end
		end
	end
	ChatBot.SendMessage( thing_to_Say )
	thing_to_Say = nil
end)

hook.Add("PlayerInitialSpawn", "ChatBot.Greet", function( ply )
	timer.Simple( 2 , function()
		if ply:IsAdmin() then
			local replacement = table.Random( AdminGreet )
			local sub = string.gsub( replacement , "<n>" , ply:Nick() )
			umsg.Start("ChatBot.Call")
				umsg.String( sub )
			umsg.End()
		end
	end)
end)